<%@page import="com.dvd.dao.dvd.*"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<jsp:include page="include/directive.jsp"></jsp:include>
<%
	String pageCount = request.getParameter("pageCount");
	List<TDvd> dvds = (List<TDvd>) request.getAttribute("List<TDvd>");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link href="css/Style002.css" rel="stylesheet" type="text/css" />
		<title>DVD情報一覧</title>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/GDJK001JS.js"></script>
		<script language="javascript" type="text/javascript">
		function showOperation(obj){
			var num = obj.substring(3);
			document.getElementById("ope"+num).style.display="block"
		}
		function hiddenOperation(obj){
			var num = obj.substring(3);
			document.getElementById("ope"+num).style.display="none"
		}
	</script>
	</head>
	<body>
		<jsp:include page="include/header.jsp"></jsp:include>
		<div id="main">
			<jsp:include page="include/left.jsp"></jsp:include>
			<div id="right">
				<%
					pageContext.setAttribute("dvdSize", dvds.size());
					for (int i = 0; i < dvds.size() && i < 15; i++) {
						String cellId = String.format("%02d", i + 1);
						TDvd dvd = dvds.get(i);
						if (i % 5 == 0) {
							out.println("<div class=\"line\">");
						}
				%>
				<div class="cell">
					<div id="img<%=cellId%>" class="context"
						onmouseover="showOperation(this.id);"
						onmouseout="hiddenOperation(this.id);">
						<a href="GDJC001.do?dvdId=<%=dvd.getFDvdId()%>"><img
								src="<%=dvd.getFImgPath()%>" />
						</a>
						<caption>
							<a href="GDJC001.do?dvdId=<%=dvd.getFDvdId()%>"><%=dvd.getFDvdTitle()%></a>
						</caption>
					</div>
					<%
						if (request.getSession().getAttribute("loginState") != null) {
					%>
					<div id="ope<%=cellId%>" class="operation"
						onmouseover="this.style.display='block';"
						onmouseout="this.style.display='none';">
						<a href="GDJC002.do?dvdId=<%=dvd.getFDvdId()%>&action=edit"><img
								src="images/edit.jpg" />
						</a>
						<a href="#" onclick="onDelete('<%=dvd.getFDvdId()%>')"><img
								src="images/delete.jpg" />
						</a>
					</div>
					<%
						}
					%>
				</div>
				<%
					if (i % 5 == 4 || i == dvds.size() - 1) {
							out.println("</div>");
						}
					}
				%>
				<div class="footer"
					style="position: absolute; left: 200px; top: 200px;">
					<%-- when search --%>
					<c:if test="${param.pageCount == '-1'}">
						<a href="GDJK001.do?pageId=1">BACK</a>
					</c:if>
					<c:if test="${pageScope.dvdSize ==0}">
						<script type="text/javascript">
				alert("Aha! NO Result!!");
			</script>
					</c:if>

					<c:if test="${pageScope.dvdSize >15}">
						<script type="text/javascript">
				alert("This search contains too many results...");
			</script>
					</c:if>
					<c:if test="${param.pageCount != '-1'}">
						<a href="GDJK001.do?pageId=1">最初頁</a>|
			｜<a href="GDJK001.do?pageId=${param.pageCount}">最後頁</a>
					</c:if>
				</div>
			</div>
		</div>
		<jsp:include page="include/footer.jsp" />
	</body>
</html>

